We can use the generic ::event signal here.
GtkAdjustment *adjustment;
int cursor_x, cursor_y;
-static void
-on_motion_notify (GtkWidget *window,
- GdkEventMotion *event)
+static gboolean
+event_cb (GtkWidget *window,
+ GdkEvent *event)
{
- if (gdk_event_get_window ((GdkEvent*)event) == gtk_widget_get_window (window))
+ if (gdk_event_get_event_type (event) == GDK_MOTION_NOTIFY &&
+ gdk_event_get_window (event) == gtk_widget_get_window (window))
{
gdouble x, y;
float processing_ms = gtk_adjustment_get_value (adjustment);
cursor_y = y;
gtk_widget_queue_draw (window);
}
+
+ return GDK_EVENT_PROPAGATE;
}
static void
gtk_widget_set_vexpand (da, TRUE);
gtk_box_pack_end (GTK_BOX (vbox), da);
- g_signal_connect (window, "motion-notify-event",
- G_CALLBACK (on_motion_notify), NULL);
+ g_signal_connect (window, "event",
+ G_CALLBACK (event_cb), NULL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
gint width, height;
gdouble x, y;
- gtk_window_get_size (GTK_WINDOW (popup), &width, &height);
- gdk_event_get_root_coords (event, &x, &y);
- gtk_window_move (GTK_WINDOW (popup),
- (int) x - width / 2,
- (int) y - height / 2);
-
- return FALSE;
+ if (gdk_event_get_event_type (event) == GDK_MOTION_NOTIFY)
+ {
+ gtk_window_get_size (GTK_WINDOW (popup), &width, &height);
+ gdk_event_get_root_coords (event, &x, &y);
+ gtk_window_move (GTK_WINDOW (popup),
+ (int) x - width / 2,
+ (int) y - height / 2);
+ }
+
+ return GDK_EVENT_PROPAGATE;
}
static gboolean
gtk_widget_set_size_request (GTK_WIDGET (popup), 20, 20);
gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (parent));
- g_signal_connect (parent, "motion-notify-event", G_CALLBACK (place_popup), popup);
+ g_signal_connect (parent, "event", G_CALLBACK (place_popup), popup);
gtk_widget_show (popup);
}
static gboolean
-gtk_focus_widget_motion_notify_event (GtkWidget *widget,
- GdkEventMotion *event)
+gtk_focus_widget_event (GtkWidget *widget,
+ GdkEvent *event)
{
GtkFocusWidget *self = GTK_FOCUS_WIDGET (widget);
gdouble x, y;
- gdk_event_get_coords ((GdkEvent *)event, &x, &y);
+ if (gdk_event_get_event_type (event) == GDK_MOTION_NOTIFY)
+ {
+ gdk_event_get_coords ((GdkEvent *)event, &x, &y);
- self->mouse_x = x;
- self->mouse_y = y;
+ self->mouse_x = x;
+ self->mouse_y = y;
- gtk_widget_queue_draw (widget);
+ gtk_widget_queue_draw (widget);
+ }
return GDK_EVENT_PROPAGATE;
}
widget_class->snapshot = gtk_focus_widget_snapshot;
widget_class->measure = gtk_focus_widget_measure;
widget_class->size_allocate = gtk_focus_widget_size_allocate;
- widget_class->motion_notify_event = gtk_focus_widget_motion_notify_event;
+ widget_class->event = gtk_focus_widget_event;
gtk_widget_class_set_css_name (widget_class, "focuswidget");
}